import json

import yaml


def read_file(file_path: str):
    with open(file_path, mode='r', encoding="utf-8") as file:
        if ".yaml" in file_path or ".yml" in file_path:
            return yaml.safe_load(file)
        elif ".json" in file_path:
            return json.load(file)
        else:
            return file.read()


def write_files(file_path: str, data: dict):
    with open(file_path, mode='w', encoding="utf-8") as file:
        if ".yaml" in file_path or ".yml" in file_path:
            yaml.dump(data, file)
        elif ".json" in file_path:
            json.dump(data, file, ensure_ascii=False)
        else:
            file.write(str(data))


if __name__ == '__main__':
    print(read_file(r'D:\dev\python\python\fiveApiTest\env\test.yaml'))
